//
//  ST_BTEmojiChildCell.swift
//  btvideo
//
//  Created by mac on 2020/7/15.
//  Copyright © 2020 JarvanZhang. All rights reserved.
//

import UIKit
import SwiftyJSON

class ST_BTEmojiChildCell: UICollectionViewCell {
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.contentView.addSubview(cover_image_view)
        cover_image_view.snp.makeConstraints { (make) in
            make.edges.equalToSuperview().inset(UIEdgeInsets.init(top: 8, left: 10, bottom: 7, right: 9))
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    fileprivate lazy var cover_image_view:UIImageView = {
         let control = UIImageView()
          control.contentMode = .scaleAspectFill
          control.clipsToBounds = true
        
//            control.backgroundColor = .random
        
          return control
     }()
    
    
    var model:BTEmojiItemModel?{
        didSet{
            
            guard let m = model else { return  }
            
            cover_image_view.pin_setImage(from: m.image.url, placeholderImage: ST_SwiftConst.shared.fetch_random_place_holder_image())
        }
    }
}


//MARK: - Model

class BTEmojiItemModel : NSObject{

    var emojiPackId : Int!
    var id : Int!
    var image : String!
    var name : String!
    var sort : Int!

    /**
     * Instantiate the instance using the passed json values to set the properties values
     */
    init(fromJson json: JSON){
        
        emojiPackId = json["emoji_pack_id"].intValue
        id = json["id"].intValue
        image = json["image"].stringValue
        name = json["name"].stringValue
        sort = json["sort"].intValue
        
        super.init()
    }
    
}
